// 检验手机号码
export const patternMobile = /^(1[3-9])\d{9}$/i;
export const isMobile = (value: string): boolean => {
	return patternMobile.test(value);
};

// 检验短信
export const isSMs = (value: string, leng = 6): boolean => {
	if (leng == 6) {
		return /^\d{6}$/.test(value);
	} else if (leng == 4) {
		return /^\d{4}$/.test(value);
	}
};

// 校验邮箱
export const patternEmail =
	/^[\w!#$%&'*+/=?^_`{|}~-]+(?:\.[\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\w](?:[\w-]*[\w])?\.)+[\w](?:[\w-]*[\w])?$/;
export const isEmail = (value: string): boolean => {
	return patternEmail.test(value);
};

// 校验密码(数字,字母，特殊字符，任意2种组合)
export const patternPassword =
	/(?=.*\d)(?=.*[a-zA-Z\W])|(?=.*[a-zA-Z])(?=.*[\d\W])|(?=.*\W)(?=.*[a-zA-Z0-9]).{6,16}/;
export const isPassword = (value: string): boolean => patternPassword.test(value);

// 非纯数字
export const patternNonNumber = /\D+/g;
// 非数字替换为空
export const noNumberToNull = (value: string): string => value.replace(patternNonNumber, '');
